var e = require;
var t = module;
var o = exports;
var Adv_skd=require("./Adv_skd");
Object.defineProperty(o, "__esModule", {value: !0});
var n = e("BaseModuleUI"),
    a = e("NotifyEventType"),
    i = e("GlobalParams"),
    r = e("AudioManager"),
    s = e("Game"),
    l = e("UIManager"),
    c = e("ShopViewUI"),
    d = e("sdkConfig"),
    h = e("AD"),
    _ = cc._decorator,
    u = _.ccclass,
    p = _.property,
    m = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.game_type_node = []),
                (t.game_mode_label = null),
                (t.task_red_dot = null),
                (t.desk_icon_btn = null),
                (t.gameTypeString = ["个人排位", "组队模式", "无尽火力"]),
                (t.uiManager = null),
                t
            );
        }
        return (
            __extends(t, e),

            (t.prototype.onDisable = function () {
                Adv_skd.default.instance.hideBannerAd();
                Adv_skd.default.instance.hideGridAdLeft();
                Adv_skd.default.instance.hideGridAdRight();
                Adv_skd.default.instance.hideGridAdTop();
                Adv_skd.default.instance.hideGridAdLeftOne();
                Adv_skd.default.instance.hideGridAdRightOne();
                Adv_skd.default.instance.hideGridAdButtom();
            }),

            (t.prototype.initView = function () {

                Adv_skd.default.instance.hideBannerAd();
                Adv_skd.default.instance.showInterstitialAd();

                d.default.platform == d.EPlatform.VIVO
                    ? this.emitEvent(a.default.SEND_BOX_PORTAL_INFO, !0)
                    : (h.default.getInstance().hideBanner(), h.default.getInstance().showBanner()),
                    (this.uiManager = cc.find("UIManager").getComponent(l.default)),
                    this.uiManager.showCoinAndZs(!0),
                    r.default.getInstance().setMusicVolume(0.5),
                    (i.GlobalParams.gameMusicName = "main_bgm"),
                    r.default.playGameBGM(),
                    (i.GlobalParams.PlayerJoinFight = !1);
                var e = i.GlobalParams.LuckyBoxInfo.value,
                    t = i.GlobalParams.PlayerSigninInfo.value;
                i.GlobalParams.AgainGameInfo
                    ? ((i.GlobalParams.AgainGameInfo = !1), this.uiManager.showPopup("MatchViewUI"))
                    : e.open_today != new Date().toLocaleDateString()
                    ? this.uiManager.showPopup("LuckyBoxViewUI")
                    : t.signin_date != new Date().toLocaleDateString() && this.uiManager.showPopup("SigninViewUI"),
                    (i.GlobalParams.ChangeGameMode = i.GlobalParams.PlayerInfo.value.change_mode),
                    this.showAddDeskInfo(),
                    this.showChangeGameMode(),
                    this.showTaskRadDot(),
                    console.log("=======Main=======", new Date().getTime() - i.GlobalParams.start_time),
                    (i.GlobalParams.MathcTimeInfo = {time: 180, open: !0, name: "", head: 0}),
                    d.default.platform == d.EPlatform.No_AD
                        ? this.updateMatchTime()
                        : h.default.getInstance().getGameTestVersion() ||
                          i.GlobalParams.JoinGuideMode.value ||
                          this.updateMatchTime();
            }),
            (t.prototype.updateMatchTime = function () {
                var e = this;
                i.GlobalParams.MathcTimeInfo.open &&
                    (i.GlobalParams.MathcTimeInfo.time--,
                    i.GlobalParams.MathcTimeInfo.time < 1 && this.uiManager.showPopup("MatchInvitationViewUI")),
                    this.scheduleOnce(function () {
                        e.updateMatchTime();
                    }, 1);
            }),
            (t.prototype.addEvent = function () {
                this.attachEvent(a.default.SEND_BOX_PORTAL_INFO, this.showBoxPortal, this),
                    this.attachEvent(a.default.SEND_UPDATE_TASK_INFO, this.showTaskRadDot, this);
            }),
            (t.prototype.showAddDeskInfo = function () {
                var e = this;
                h.default.getInstance().desktopFlag(function (t) {
                    e.desk_icon_btn.active =
                        t == h.ResultEnum.Success &&
                        !i.GlobalParams.addDeskIcon.value &&
                        d.default.platform != d.EPlatform.TikTok;
                });
            }),
            (t.prototype.showTaskRadDot = function () {
                this.task_red_dot.active = !1;
                for (var e = i.GlobalParams.PlayerTaskInfo.value, t = 0; t < s.default.task_over_info.length; t++) {
                    var o = e.schedule[t],
                        n = s.default.task_over_info[t];
                    if (((this.task_red_dot.active = -1 != o && o >= n), this.task_red_dot.active)) break;
                }
            }),
            (t.prototype.OnClick = function (t) {
                switch ((e.prototype.OnClick.call(this, t), t.node.name)) {
                    case "begin_btn":
                        (i.GlobalParams.MathcTimeInfo.open = !1), (i.GlobalParams.MathcTimeInfo.name = "");
                        var o = i.GlobalParams.PlayerInfo.value;
                        (o.change_mode = i.GlobalParams.ChangeGameMode),
                            (i.GlobalParams.PlayerInfo.value = o),
                            1 != i.GlobalParams.ChangeGameMode
                                ? this.uiManager.showPopup("MatchViewUI")
                                : this.uiManager.showPopup("InviteViewUI");
                        break;
                    case "btn_sy_qd":
                        this.uiManager.showPopup("SigninViewUI");
                        break;
                    case "btn_sy_pws":
                        (i.GlobalParams.ChangeGameMode = 0), this.showChangeGameMode();
                        break;
                    case "btn_sy_tds":
                        (i.GlobalParams.ChangeGameMode = 1), this.showChangeGameMode();
                        break;
                    case "btn_sy_xsms":
                        (i.GlobalParams.ChangeGameMode = 2), this.showChangeGameMode();
                        break;
                    case "btn_sy_wdyx":
                        this.uiManager.showPopup("HeroCardViewUI");
                        break;
                    case "btn_sy_mfyx":
                        this.uiManager.showPopup("LuckyBoxViewUI");
                        break;
                    case "btn_sy_sc":
                        this.uiManager.showPopup("ShopViewUI", function (e) {
                            e.getComponent(c.default).showShopTypeInfo("shop_all_btn");
                        });
                        break;
                    case "btn_sy_tfwh":
                        this.uiManager.showPopup("DowerViewUI");
                        break;
                    case "btn_sy_hjjl":
                        this.uiManager.showPopup("SeasonViewUI");
                        break;
                    case "btn_sy_rw":
                        this.uiManager.showPopup("TaskViewUI");
                        break;
                    case "btn_sy_sz":
                        this.uiManager.showPopup("SettingViewUI");
                        break;
                    case "head_btn":
                        this.uiManager.showPopup("AmendPlayerInfoViewUI");
                        break;
                    case "btn_sy_zbjs":
                        this.uiManager.showPopup("EquipViewUI");
                        break;
                    case "btn_sy_tjzm":
                        this.uiManager.showPopup("DesktopPopup");
                }
            }),
            (t.prototype.showChangeGameMode = function () {
                for (var e = 0; e < this.game_type_node.length; e++)
                    this.game_type_node[e].children[0].active = e == i.GlobalParams.ChangeGameMode;
                this.game_mode_label.string = "" + this.gameTypeString[i.GlobalParams.ChangeGameMode];
            }),
            (t.prototype.showBoxPortal = function (e, t) {
                t
                    ? d.default.platform == d.EPlatform.VIVO &&
                      h.default.getInstance().getNavigateBoxPortalFlag() &&
                      (h.default.getInstance().hideBanner(), h.default.getInstance().showNavigateBoxPortal())
                    : d.default.platform == d.EPlatform.VIVO &&
                      (h.default.getInstance().showBanner(), h.default.getInstance().hideNavigateBoxPortal());
            }),
            __decorate([p(cc.Node)], t.prototype, "game_type_node", void 0),
            __decorate([p(cc.Label)], t.prototype, "game_mode_label", void 0),
            __decorate([p(cc.Node)], t.prototype, "task_red_dot", void 0),
            __decorate([p(cc.Node)], t.prototype, "desk_icon_btn", void 0),
            __decorate([u], t)
        );
    })(n.default);
o.default = m;
